import axios from "axios";
import {useStore} from "../pinia/index.js";

const request = axios.create({
    baseURL: "/api", timeout: 5000,
});
// 配置axios 拦截器
request.interceptors.request.use((config) => {
    //携带token 令牌
    const store = useStore()
    config.headers.Lctoken = store.token

    return config;
}, (error) => {
    return Promise.reject(error);
});

request.interceptors.response.use((response) => {
    if(response.status === 200){
        return response.data;
    }
    return response;
})

export {request}
